import Vue from 'vue'
import Vuex from 'vuex'
import persisted from 'vuex-persistedstate'

Vue.use(Vuex)
Vue.use(persisted)

export default new Vuex.Store({
  state: {
    list: [],
    copylist:[]
  },
  mutations: {
    changelist(state, obj) {
      if (obj.type == 'add') {
        state.list.unshift(obj)
        state.copylist=JSON.parse(JSON.stringify(state.list))
      }else if(obj.type=='del'){
        state.list.splice(obj.index,1)
      }
    }
  },
  
  actions: {},
  modules: {},
  plugins: [persisted()]
})